package reflect;

import thread.MapChartServer;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;

/**
 * @Author: Miyako
 * @Date: 2024-07-23-10:56
 * @Description:
 */
public class MethodDemo01 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, URISyntaxException {
        ArrayList<String> list = new ArrayList<>();
        list.add("hello");
        list.add("world");
        java.lang.Class clazz1 = ArrayList.class;//上下面两种方式获取的Class对象是同一个
        Method  m = clazz1.getMethod("add",Object.class);
//        m.invoke(list, 0,300);//这个方法会在运行时候，自动调用ArrayList的add方法，导致list的泛型失效
        for (Object o : list)
        System.out.println( o);
        System.out.println(list);
//       System.out.println(list.get(0));
        System.out.println(MapChartServer.class);
       URI uri = MapChartServer.class.getResource("./").toURI();
        System.out.println(MapChartServer.class.getClassLoader());
       URI uri1 = MapChartServer.class.getClassLoader().getResource("./").toURI();
        System.out.println(uri);
        System.out.println(uri1);

    }
}
